package be.ac.ua.ecampus.cmat;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;


public class DBConnection {

	public static Connection connect(String url, String driver) {
		Connection connection = null;
		try {
			Class.forName(driver);
			connection = DriverManager.getConnection(url);
		} catch (ClassNotFoundException e) {
			System.out.println("[CMAT ERROR] - [DBConnection] - connect(String url, String driver)");
		} catch (SQLException e) {
			System.out.println("[CMAT ERROR] - [DBConnection] - Could not connect to the database.");
		}
		return connection;
	}
	
	/*
	 * 
	 */
	public static Connection connect() {
		final String url = "jdbc:mysql://localhost:3306/student2011?user=student2011&password=parajan2011";
		final String driver = "com.mysql.jdbc.Driver";
		return connect(url, driver);
	}
}
